public class test05 {
    class Solution {
        public int eraseOverlapIntervals(int[][] intervals) {
            Arrays.sort(intervals,(a,b)->Integer.compare(a[0],b[0]));
            int res = 0;
            int rightRange = intervals[0][1];
            //有重叠就加一个
            for(int i = 1;i<intervals.length;i++){
                if(intervals[i][0]>=rightRange){
                    rightRange = intervals[i][1];
                }else{
                    rightRange = Math.min(rightRange,intervals[i][1]);
                    res++;
                }
            }
            return res;
        }
    }
}
